Skip to content

Conversation

Solventerritory
Copy link

@Solventerritory Solventerritory commented Oct 4, 2025

This PR updates the documentation and header comments for the mjs_addDefault function to clarify its correct usage. It now explicitly states that only one unnamed default is allowed at the top level, and all other defaults should be named by passing a non-null classname. Example usage is also provided.

This is in regard to issue #2707

Changes:

Added a descriptive comment and example usage for mjs_addDefault in:
references.h
mujoco.h
user_api.h
Clarifies that only one unnamed default is allowed at the top level.
Shows how to use named and unnamed defaults correctly.
Motivation:
This change helps prevent user errors and invalid XML generation by making the API contract explicit in the documentation and headers. It addresses confusion around unnamed defaults and ensures users follow MuJoCo’s requirements for default classes.

Checklist:

Documentation updated
Example usage provided
No breaking changes to API

@Solventerritory
Copy link
Author

How is the working code? Anything else to be done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant